"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/5/29 10:01
@Description :
"""
import time

"""
from zhipuai import ZhipuAI
client = ZhipuAI(api_key="1b227115722d474da20a2a310377dc7a.5V66XS8JAaQhWG4o") # 填写您自己的APIKey
# user_ask = input('>>')
response = client.chat.completions.create(
    model="GLM-4-Flash-250414",  # 填写需要调用的模型编码
    messages=[
        {"role": "user", "content": user_ask}
    ],
)
print("assistant>>",response.choices[0].message.content)
"""

from zhipuai import ZhipuAI
client = ZhipuAI(api_key="1b227115722d474da20a2a310377dc7a.5V66XS8JAaQhWG4o") # 请填写您自己的APIKey

while True:
    user_ask = input('>>')
    if user_ask == "exit":
        break
    response = client.chat.completions.create(
        model="GLM-4-Flash-250414",  # 填写需要调用的模型编码
        messages=[
            {"role": "system", "content": "你是一个幽默专家,会讲很多的笑话"},
            {"role": "user", "content": user_ask},
        ],
        stream=True,
    )
    print("assistant>>",end='')
    for chunk in response:
        time.sleep(0.2)
        print(chunk.choices[0].delta.content,end='')